﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Medical_Store_Billing.Business_Login_Layer;
using Microsoft.Reporting.WinForms;

namespace Medical_Store_Billing.Report
{
    public partial class FormReport2 : Form
    {
        PhieunhapBLL m_Phieunhap;
        public FormReport2()
        {
            InitializeComponent();
        }

        private void FormReport2_Load(object sender, EventArgs e)
        {

            this.reportViewer1.RefreshReport();
            m_Phieunhap = new PhieunhapBLL();
            comboBox1.DataSource = m_Phieunhap.Laydsphieunhap();
            comboBox1.DisplayMember = "maphieunhap";
            comboBox1.ValueMember = "maphieunhap";

        }

        private void button1_Click(object sender, EventArgs e)
        {
            m_Phieunhap = new PhieunhapBLL();
            DataTable tb =m_Phieunhap.Timphieunhap(comboBox1.SelectedValue.ToString());
            string ngay = tb.Rows[0][1].ToString();
            string tongtien = tb.Rows[0][2].ToString();
            string manv = tb.Rows[0][3].ToString();
            string nguoilap = textBox2.Text;
            string maphieunhap = comboBox1.SelectedValue.ToString();

            IList<ReportParameter> param = new List<ReportParameter>();

            param.Add(new ReportParameter("nguoilap", nguoilap));
            param.Add(new ReportParameter("tongtien", tongtien));
            param.Add(new ReportParameter("manv", manv));
            param.Add(new ReportParameter("ngay", ngay));
            param.Add(new ReportParameter("maphieunhap", maphieunhap));

            reportViewer1.LocalReport.SetParameters(param);

            m_Phieunhap = new PhieunhapBLL();
            chitietnhapclassBindingSource.DataSource = m_Phieunhap.laychitietphieunhap(maphieunhap);
            reportViewer1.RefreshReport();
        }
    }
}
